from greenlet import greenlet

def test1():
    print(12)
    g2.switch()  # 切换到g2
    print(34)
    g2.switch()
def test2():
    print(56)
    g1.switch()
    print(78)


g1 = greenlet(test1)  # 需要执行的函数
g2 = greenlet(test2)
g1.switch()  # 主程序切换到g1
